#include "ControlPointStruct.h"

ControlPointStruct::ControlPointStruct()
{
    m_address = 0;
    m_value = 0;
    m_delayTime = 0;
    m_Portlist.clear();
 //   m_targe.setType("UART");
  //  m_targe.setName("RS485");
}
quint16 ControlPointStruct::address() const
{
    return m_address;
}

void ControlPointStruct::setAddress(const quint16 &address)
{
    m_address = address;
}
quint16 ControlPointStruct::value() const
{
    return m_value;
}

void ControlPointStruct::setValue(const quint16 &value)
{
    m_value = value;
}
quint64 ControlPointStruct::delayTime() const
{
    return m_delayTime;
}

void ControlPointStruct::setDelayTime(quint64 delayTime)
{
    m_delayTime = delayTime;
}

quint8 ControlPointStruct::thirdFuncLen() const
{
    return m_thirdFuncLen;
}
void ControlPointStruct::setThirdFuncLen(quint8 len)
{
    m_thirdFuncLen = len;
}

QByteArray ControlPointStruct::thirdFuncList() const
{
    return m_thirdFuncArray;
}
void ControlPointStruct::setThirdFuncList(QByteArray list)
{
   m_thirdFuncArray = list;
}
/*
quint16 ControlPointStruct::knxGroupeAddress() const
{
    return m_knxGroupAddress;
}
void ControlPointStruct::setKnxGroupeAddress(quint16 address)
{
    m_knxGroupAddress = address;
}

quint16 ControlPointStruct::knxLen() const
{
    return m_knxLen;
}
void ControlPointStruct::setKnxLen(quint16 len)
{
    m_knxLen = len;
}

QByteArray ControlPointStruct::knxDataList() const
{
    return m_knxDataList;
}
void ControlPointStruct::setKnxDataList(QByteArray dataList)
{
    m_knxDataList = dataList;
}
*/

QList<QString> ControlPointStruct::Portlist() const
{
    return m_Portlist;
}
void ControlPointStruct::JoinPortList(QString data)
{
    m_Portlist.append(data);
}

void ControlPointStruct::clearnPortList()
{
    m_Portlist.clear();
}
//void ControlPointStruct::setPortStruct(const PortStruct &Targe)
//{
//    m_targe=Targe;
//}
//PortStruct ControlPointStruct::getPortStruct()const
//{
//    return m_targe;
//}

bool ControlPointStruct::operator ==(const ControlPointStruct &rhs) const
{
    if((m_address >0)||(m_value > 0))
    return ((m_address == rhs.address()) && (m_value == rhs.value()));
    else
    {
        return (m_thirdFuncArray == rhs.m_thirdFuncArray);
    }
}

bool ControlPointStruct::operator <(const ControlPointStruct &rhs) const
{
    if (m_address < rhs.address())
    {
        return true;
    }
    else if (m_address == rhs.address())
    {
        return m_value < rhs.value();
    }

    return false;
}

//void ControlPointStruct::setPortList(QStringList QSlist)
//{
//    m_PortList=QSlist;
//}
//QStringList ControlPointStruct::PortList()
//{
//   return m_PortList;
//}


QDebug operator <<(QDebug debug, const ControlPointStruct &controlPoint)
{
    debug<<"Address:"<<controlPoint.address()<<",Value:"<<controlPoint.value();
    return debug;
}

uint qHash(const ControlPointStruct &key)
{
    return key.address()+key.value();
}

